//
//  CBattleManager.h
//  Monster_Martial_Arts_Version_0
//
//  Created by chiawei.tseng on 13/1/4.
//
//

#ifndef Monster_Martial_Arts_Version_0_CBattleManager_h
#define Monster_Martial_Arts_Version_0_CBattleManager_h

#include "cocos2d.h"
#include "Singleton.h"
#include "CObject.h"
#include "CBattleObject.h"
#include "BattleDef.h"
//#include <map>
#include <vector>

using namespace cocos2d;
using namespace std;
using namespace MMA;

typedef vector<CBattleObject*> TeamMember;
typedef vector<CBattleObject*>::iterator TeamMemberIter ;

struct TEAM
{
    //BATTLE_TEAM_NUMBER m_battleTeamNumber;
    
    TeamMember         m_TeamMember;
    
    //bool               m_bIsRegister;
    
    
};

class CBattleManager :public Singleton<CBattleManager>
{
public:
    
    CBattleManager();
    ~CBattleManager();
    
    virtual void Init();
    //void    Release();
    
    //void    Start();
    //void    Leaving();
    
    
    void    RegisterLayer(CCNode*);
    void    UnRegisterLayer();
    CCNode* GetBattleLayer();
    
    
    TEAM&   GetTeam(BATTLE_TEAM_NUMBER);
    /*
    void    RegisterTeam(BATTLE_TEAM_NUMBER,TEAM);
    void    UnRegister(BATTLE_TEAM_NUMBER);
    */
    void    AddTeamMember(BATTLE_TEAM_NUMBER, CBattleObject*);
    void    CleanAllTemMember(BATTLE_TEAM_NUMBER);
    
    CBattleObject*    GetTeamMember(BATTLE_TEAM_NUMBER , int);
    
    inline  int       GetTeamMemberTotal(BATTLE_TEAM_NUMBER);
        
private:
    
    
    TEAM    m_Team[BATTLE_TEAM_NUMBER_MAX];
    
    CCNode* m_pBattleLayer;
    
    
};

int CBattleManager::GetTeamMemberTotal(BATTLE_TEAM_NUMBER battleTeamNumber)
{
    CCAssert(battleTeamNumber < BATTLE_TEAM_NUMBER_MAX, "battleTeamNumber >= BATTLE_TEAM_NUMBER_MAX");
    
    return m_Team[battleTeamNumber].m_TeamMember.size();
}

#endif
